package com.baomidou.run.service.impl;

import com.baomidou.run.entity.TbQualification;
import com.baomidou.run.dto.TbTestDto;
import com.baomidou.run.entity.TbTest;
import com.baomidou.run.mapper.TbTestMapper;
import com.baomidou.run.service.ITbTestService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mp
 * @since 2023-03-15
 */
@Service
public class TbTestServiceImpl extends ServiceImpl<TbTestMapper, TbTest> implements ITbTestService {

    @Autowired
    private TbTestMapper tbTestMapper;

    @Override
    public List<TbTestDto> selectMpjList(TbTest tbTest) {

        MPJLambdaWrapper<TbTest> wrapper = new MPJLambdaWrapper();
        wrapper.selectAll(TbTest.class);
        wrapper.selectAs(TbQualification::getQualificationName,TbTestDto::getQualificationName);
        wrapper.leftJoin(TbQualification.class,TbQualification::getId,TbTest::getQualification);
        wrapper.like(TbTest::getName,tbTest.getName());
        return tbTestMapper.selectJoinList(TbTestDto.class,wrapper);
    }
}
